package com.itheima.chapter08.set.map.hashmap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

//ArrayList集合存储HashMap元素并遍历
public class Hashmapdemo3 {
    public static void main(String[] args) {
        ArrayList<HashMap<String, String>> arr = new ArrayList<>();
        HashMap<String, String> hm1 = new HashMap<>();
        hm1.put("zhangsan", "23");
        hm1.put("lisi", "25");
        HashMap<String, String> hm2 = new HashMap<>();
        hm2.put("wangwu", "33");
        hm2.put("sunliu", "56");
        HashMap<String, String> hm3 = new HashMap<>();
        hm3.put("zhouyi", "33");
        hm3.put("liqe", "29");
        arr.add(hm1);
        arr.add(hm2);
        arr.add(hm3);
        for (HashMap<String, String> hm : arr) {
            Set<String> keySet = hm.keySet();
            for (String key : keySet) {
                String value = hm.get(key);
                System.out.println(key + " " + value);
            }
        }
    }
}
